#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:homework1_9.py
# author:wmf
# datetime:2021/3/14 22:10
# software: PyCharm
'''
this is function description
'''
# import module your need

#9 设计一个猜数字 游戏；最多只能猜测N次，在N次之内猜不出，就退出程序，提示猜测失败；

from random import randint

print('欢迎来到猜数字游戏,数字范围(0-100):')

N = input("输入要猜的次数:")

x = (randint(0,100))

judge = 0

n = 1#答题次数
while(n<=eval(N) and judge == 0):
    print("(第%d次)"%n)
    guess = input("输入你猜的数:")
    if(eval(guess)<x):
        print("你猜的数小了")
    elif(eval(guess)>x):
        print("你猜的数大了")
    else:
        print("恭喜你!猜对了!")
        judge = 1
    n = n + 1
    if(n>eval(N)):
        print("答题结束,真确答案是:%d"%x)


